﻿using System.Diagnostics.Contracts;

namespace System.Reactive
{
	[ContractClass(typeof(ObserverBaseContract<>))]
	public abstract class ObserverBase<T> : IObserver<T>, IDisposable
	{
		protected abstract void Completed();
		protected abstract void Error(Exception error);
		protected abstract void Next(T value);

		public void OnCompleted()
		{
		}

		public void OnError(Exception error)
		{
		}

		public void OnNext(T value)
		{
		}

		public void Dispose()
		{
		}
	}

	[ContractClassFor(typeof(ObserverBase<>))]
	internal abstract class ObserverBaseContract<T> : ObserverBase<T>
	{
		protected override void Completed()
		{
		}

		protected override void Error(Exception error)
		{
			Contract.Requires(error != null, null, "error != null");
		}

		protected override void Next(T value)
		{
		}
	}
}